home *** CD-ROM | disk | FTP | other *** search
/ Sprite 1984 - 1993 / Sprite 1984 - 1993.iso / src / cmds / rawstat / rawmig.c < prev    next >
Encoding:
C/C++ Source or Header  |  1990-09-24  |  4.8 KB  |  140 lines

  1. /* 
  2.  * rawmig.c --
  3.  *
  4.  *    Print raw format MIGRATION statistics.
  5.  *
  6.  * Copyright (C) 1990 Regents of the University of California
  7.  * Permission to use, copy, modify, and distribute this
  8.  * software and its documentation for any purpose and without
  9.  * fee is hereby granted, provided that the above copyright
  10.  * notice appear in all copies.  The University of California
  11.  * makes no representations about the suitability of this
  12.  * software for any purpose.  It is provided "as is" without
  13.  * express or implied warranty.
  14.  */
  15.  
  16. #ifndef lint
  17. static char rcsid[] = "$Header: /sprite/src/cmds/rawstat/RCS/rawmig.c,v 1.2 90/09/24 14:40:32 douglis Exp $ SPRITE (Berkeley)";
  18. #endif /* not lint */
  19.  
  20. #include "sprite.h"
  21. #include "stdio.h"
  22. #include "mig.h"
  23.  
  24.  
  25. /*
  26.  *----------------------------------------------------------------------
  27.  *
  28.  * PrintRawMigStat --
  29.  *
  30.  *    Prints Mig_Stats structure maintained by migration daemon.
  31.  *
  32.  * Results:
  33.  *    None.
  34.  *
  35.  * Side effects:
  36.  *    Opens connection to daemon.
  37.  *
  38.  *----------------------------------------------------------------------
  39.  */
  40.  
  41. PrintRawMigStat()
  42. {
  43.     Mig_Stats stats;        /* statistics buffer */
  44.     Mig_Stats *X = &stats;
  45.     Mig_ArchStats *A;
  46.     int status;
  47.     int i;
  48.     int j;
  49.     double overflowFactor;
  50.  
  51.     if (Mig_GetStats(&stats) < 0) {
  52.     return;
  53.     }
  54. #ifdef MIG_STATS_VERSION
  55.     if (stats.version != MIG_STATS_VERSION) {
  56.     return;
  57.     }
  58. #endif
  59.     printf("Migration daemon stats\n");
  60.  
  61.  
  62.     ZeroPrint("version   %8u\n", X->version);
  63.     ZeroPrint("checkpointInterval        %8u\n", X->checkpointInterval);
  64.     ZeroPrint("firstRun         %8u\n", X->firstRun);
  65.     ZeroPrint("restarts        %8u\n", X->restarts);
  66.     ZeroPrint("intervals          %8u\n", X->intervals);
  67.     ZeroPrint("maxArchs        %8u\n", X->maxArchs);
  68.     ZeroPrint("getLoadRequests         %8u\n", X->getLoadRequests);
  69.     ZeroPrint("totalRequests         %8u\n", X->totalRequests);
  70.     ZeroPrint("totalObtained         %8u\n", X->totalObtained);
  71.     ZeroPrint("numRepeatRequests         %8u\n", X->numRepeatRequests);
  72.     ZeroPrint("numRepeatAssignments         %8u\n", X->numRepeatAssignments);
  73.     ZeroPrint("numFirstAssignments         %8u\n", X->numFirstAssignments);
  74.  
  75.     for (i = 0; i < X->maxArchs; i++) {
  76.     A = &X->archStats[i];
  77.     if (strcmp(A->arch, "sun4") && strcmp(A->arch, "ds3100")) {
  78.         continue;
  79.     }
  80.     printf("Migration daemon %s stats\n", A->arch);
  81.  
  82.     ZeroPrint("numClients         %8u\n", A->numClients);
  83.     ZeroPrint("gotAll         %8u\n", A->gotAll);
  84.  
  85.     for (j = 0; j <= MIG_MAX_HOSTS_DIST; j++) {
  86.         printf("request%d         %8u\n", j, A->requestDist[j]);
  87.         printf("obtained%d         %8u\n", j, A->obtainedDist[j]);
  88.     }
  89.     ZeroPrint("nonIdleTransitions         %8u\n", A->nonIdleTransitions);
  90.  
  91.     ZeroPrint("requested         %8u\n", A->counters.requested);
  92.     ZeroPrint("requested:square         %8u\n", A->squared.requested);
  93.     ZeroPrint("obtained         %8u\n", A->counters.obtained);
  94.     ZeroPrint("obtained:square         %8u\n", A->squared.obtained);
  95.     ZeroPrint("evicted         %8u\n", A->counters.evicted);
  96.     ZeroPrint("evicted:square         %8u\n", A->squared.evicted);
  97.     ZeroPrint("reclaimed         %8u\n", A->counters.reclaimed);
  98.     ZeroPrint("reclaimed:square         %8u\n", A->squared.reclaimed);
  99.     ZeroPrint("timeUsed         %8u\n", A->counters.timeUsed);
  100.     ZeroPrint("timeUsed:square         %8u\n", A->squared.timeUsed);
  101.     ZeroPrint("timeToEviction         %8u\n", A->counters.timeToEviction);
  102.     ZeroPrint("timeToEviction:square         %8u\n",
  103.           A->squared.timeToEviction);
  104.  
  105.     /*
  106.      * For "pseudo-double" variables -- two integers -- we need to store
  107.      * them in this program as real double variables.  The problem is,
  108.      * we can't just convert 0x80000000 from an unsigned int to float, because
  109.      * our C compiler goofs and makes the result negative.  Therefore, some
  110.      * tricks to take the constant and turn it into a number
  111.      * we can use to multiply by the overflow counter.  Shift it right, then
  112.      * multiply it by the equivalent number once it's a "double".  
  113.      */
  114.     overflowFactor = (((unsigned) 0x80000000) >> 1) * 2.0;
  115.     
  116. #define TO_DOUBLE(array) \
  117.     (array[MIG_COUNTER_LOW] + array[MIG_COUNTER_HIGH] * overflowFactor)
  118.  
  119.     printf("hostIdleObtained         %8.0f\n",
  120.           TO_DOUBLE(A->counters.hostIdleObtained));
  121.     printf("hostIdleObtained:square         %8.0f\n",
  122.           TO_DOUBLE(A->squared.hostIdleObtained));
  123.     printf("hostIdleEvicted         %8.0f\n",
  124.           TO_DOUBLE(A->counters.hostIdleEvicted));
  125.     printf("hostIdleEvicted:square         %8.0f\n",
  126.           TO_DOUBLE(A->squared.hostIdleEvicted));
  127.     printf("idleTimeWhenActive         %8.0f\n",
  128.           TO_DOUBLE(A->counters.idleTimeWhenActive));
  129.     printf("idleTimeWhenActive:square         %8.0f\n",
  130.           TO_DOUBLE(A->squared.idleTimeWhenActive));
  131.     
  132.     for (j = 0; j < MIG_NUM_STATES; j++) {
  133.         printf("state%d         %8u\n", j, A->counters.hostCounts[j]);
  134.         printf("state%d:square         %8u\n", j, A->squared.hostCounts[j]);
  135.     }
  136.     }
  137. }
  138.  
  139.  
  140.